<template>
  <div>
    <el-row :gutter="15">
      <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px">
        <el-col :span="17">
          <el-form-item label="收货人姓名" prop="orderInfoName">
            <el-input v-model="formData.orderInfoName" placeholder="请输入收货人姓名" clearable
              :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="17">
          <el-form-item label="收货人电话" prop="shoppAddreTel">
            <el-input v-model="formData.shoppAddreTel" placeholder="请输入收货人电话" clearable
              :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
       
        <el-col :span="17">
          <el-form-item label="订单总金额" prop="orderInfoSalePrice">
            <el-input v-model="formData.orderInfoSalePrice" placeholder="请输入订单总金额" clearable
              :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="17">
          <el-form-item label="商品总金额" prop="commodCountPrice">
            <el-input v-model="formData.commodCountPrice" placeholder="请输入商品总金额" clearable
              :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="支付方式" prop="payWayInfoId">
            <el-radio-group v-model="formData.payWayInfoId" size="medium">
              <el-radio-button v-for="(item, index) in payWayInfoIdOptions" :key="index" :label="item.value"
                :disabled="item.disabled">{{item.label}}</el-radio-button>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="17">
          <el-form-item label="实付金额" prop="orderInfoPayPrice">
            <el-input v-model="formData.orderInfoPayPrice" placeholder="请输入实付金额" clearable
              :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="是否发货" prop="orderWheShipments">
            <el-radio-group v-model="formData.orderWheShipments" size="medium">
              <el-radio-button v-for="(item, index) in orderWheShipmentsOptions" :key="index"
                :label="item.value" :disabled="item.disabled">{{item.label}}</el-radio-button>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item size="large">
            <el-button type="primary" @click="submitForm">提交</el-button>
            <el-button @click="resetForm">重置</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>
  </div>
</template>
<script>
export default {
  components: {},
  props: [],
  data() {
    return {
      formData: {
        orderInfoName: undefined,
        shoppAddreTel: undefined,
        orderInfoSalePrice: undefined,
        commodCountPrice: undefined,
        
        payWayInfoId: 1,
        orderInfoPayPrice: undefined,
        orderWheShipments: 2,
      },
      rules: {
        orderInfoName: [{
          required: true,
          message: '请输入收货人姓名',
          trigger: 'blur'
        }],
        
        shoppAddreTel: [{
          required: true,
          message: '请输入收货人电话',
          trigger: 'blur'
        }],
        orderInfoSalePrice: [{
          required: true,
          message: '请输入订单总金额',
          trigger: 'blur'
        }],
        commodCountPrice: [{
          required: true,
          message: '请输入商品总金额',
          trigger: 'blur'
        }],
        payWayInfoId: [{
          required: true,
          message: '支付方式不能为空',
          trigger: 'change'
        }],
        orderInfoPayPrice: [{
          required: true,
          message: '请输入实付金额',
          trigger: 'blur'
        }],
        orderWheShipments: [{
          required: true,
          message: '是否发货不能为空',
          trigger: 'change'
        }],
      },
      payWayInfoIdOptions: [{
        "label": "支付宝",
        "value": 1
      }],
      orderWheShipmentsOptions: [{
        "label": "是",
        "value": 1
      }, {
        "label": "否",
        "value": 2
      }],
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    submitForm() {
      this.$refs['elForm'].validate(valid => {
        if (!valid) return
        // TODO 提交表单
        this.axios
        .post("https://localhost:44347/api/app/p-order/order-servie",this.formData)
        .then(s=>{
            if(s.data>0)
            {
                alert("订单加入成功")
            }
            else
            {
                alert("订单加入失败")
            }
        })
      })
    },
    resetForm() {
      this.$refs['elForm'].resetFields()
    },
  }
}

</script>
<style>
</style>
